package demo;

import java.nio.charset.StandardCharsets;

public class Demo03 {
    public static void main(String[] args) {
        /*
         * Unicode 转换为 UTF-8 时候，英文在（0~127范围）是一字节编码
         */
        System.out.println("字符的Unicode码编：");
        String str = "A"; //65 = 01000001
        System.out.println(Integer.toBinaryString(str.charAt(0)));

        System.out.println("UTF-8 编码：");
        byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
        System.out.println(bytes.length); //1字节
        System.out.println(Integer.toBinaryString(bytes[0]));
    }
}
